home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / CUGUK / APPLICAT / C034.ZIP / DBQ.HLP < prev    next >
Text File  |  2010-11-01  |  11KB  |  448 lines

  1.  
  2. DBQ - Commands
  3. ==============
  4. CREATE database fieldname type size [scale] [fieldname type size [scale]]
  5. ERASE database
  6. RENAME database newname
  7. INSERT database
  8. DELETE selection ;
  9. UPDATE fieldnames OF selection ;
  10. PRINT [USING formatfile] fieldnames OF selection [INTO reportfile] ;
  11. FIND fieldnames OF selection ;
  12. SORT database BY fieldname [direction] [fieldname [direction]] ;
  13. IMPORT datafile INTO database
  14. EXPORT [DELETED] database [INTO datafile] ;
  15. EXTRACT database [INTO definitionfile] ;
  16. COMPRESS database
  17. DEFINE procedure / ENTER procedure
  18. SHOW {procedure} ;
  19. SET [NO] [FOLD] [VERIFY] [LOG] [PAGE [pagelength]] ;
  20. HELP
  21. EXIT
  22.  
  23. ?<
  24.  
  25. Syntax
  26. ======
  27. database, newname    : database file name (Identifier) (Ext. .DBQ)
  28. fieldnames        : qualfieldname[+] [, qualfieldname[+] ...] | all[+]
  29. qualfieldname        : [database.]fieldname
  30. fieldname        : field name (identifier)
  31. type : NUM | CHAR / size : 1 to 12 NUM, 1 to 128 CHAR / scale : 0 to 10
  32. direction        : ASC (default) | DESC
  33. selection        : database [, database ... ] WITH expression
  34. expression        : [NOT] comparison [AND | OR [NOT] comparison ...]
  35. comparison        : primary relation primary
  36. primary            : qualfieldname | string | number
  37. relation        : = | > | < | >= | <= | <> | }
  38. procedure        : procedure name (Identifier)
  39. pagelength        : length of paper in lines less 6 for heading
  40. datafile        : data file name (Identifier) (Ext. .DAT)
  41. formatfile        : format file name (Identifier) (Ext. .FMT)
  42. reportfile        : report file name (Identifier) (Ext. .REP)
  43. definitionfile        : definition file (Identifier) (Ext. .DEF)
  44. identifier        : Alpha [ alpha | "_" ...]
  45.  
  46. ?c
  47.  
  48. Create database
  49. ===============
  50.  
  51. create <database> <fname> <ftype> <flen> [<fscale>] . . . ;
  52.  
  53. Where
  54.     database    ::=    database name
  55.     fname        ::=    field name
  56.     ftype        ::=    (CHAR | NUM)
  57.     flen        ::=    field length
  58.     fscale        ::=    field scale (decimal places) - default 0
  59.  
  60. Example
  61.     create accounts name char 10 acc_num num 6 balance num 8 2 ;
  62.  
  63. ?i
  64.  
  65. Insert records
  66. ==============
  67.  
  68. insert <database>
  69.  
  70. Prompts for fields in record. Brackets show the width of the field.
  71. [string] and <numeric> fields are indicated by the type of bracket.
  72. A number after <numeric> brackets indicates the number of decimal places.
  73. Pressing ENTER for first field terminates input.
  74.  
  75. Example:-
  76.  
  77.     insert accounts
  78.  
  79. name         [          ]
  80. acc_num         <      >
  81. balance         <        > 2
  82. ------
  83. name         [          ]
  84.  
  85. ?u
  86.  
  87. Update records
  88. ==============
  89.  
  90. update {<fields> | all } of <selection>;
  91.  
  92. Where
  93.  - <fields> is a field list
  94.  - <selection> is a record selection expression
  95.  
  96. This allows you to update the specified fields in the selected
  97. records. The original value is printed first, and a prompt is issued
  98. to allow a new value to be input. If no value is entered before
  99. pressing ENTER, the original value is retained.
  100.  
  101. Example
  102. -------
  103.  
  104. update balance of accounts with name = "john smith";
  105.  
  106. balance        = 2.34
  107. balance         <       > 2
  108.  
  109. ?p
  110.  
  111. Print selected fields from selected records
  112. ===========================================
  113.  
  114. print [using <filename>] [{ <field>[+], <field>[+] . . . | all[+] }
  115.     of] <selection> [into <tname>] ;
  116.  
  117. Where
  118.  
  119.  - using <filename> indicates a format file (ext=.FMT)
  120.     will be used for output formatting.
  121.  - <field>[+] is an optionally qualified field name with optional
  122.     totalling (+) specified for numeric fields.
  123.  - all indicates all fields with optional totalling (+) of all
  124.     numeric fields
  125.  - <selection> is a record selection expression
  126.  - <tname> is the name of an output file (ext=.TXT) to be used instead of the
  127.     terminal for output. (LST will cause output to the printer).
  128.  
  129. Example
  130. -------
  131. print name, acc_num, balance+ of accounts with name } "smith";
  132.  
  133. ?s
  134.  
  135. Find records
  136. ============
  137.  
  138. find { <field>, <field> . . . | all } of <selection> ;
  139.  
  140. Where
  141.  
  142.  - <field> is an optionally qualified field name
  143.  - all indicates all fields (can use * instead of 'all')
  144.  - <selection> is a record selection expression
  145.  
  146. Creates a database called "current" containing the selected records.
  147.  
  148. Example
  149. -------
  150. find name, acc_num of accounts with name } "smith";
  151. rename current smiths
  152. print;
  153.  
  154. ?i
  155.  
  156. Import records from a file
  157. ==========================
  158.  
  159. import <filename> into <database>
  160.  
  161. Where
  162.  - <filename> is the name of a data file (ext .DAT) containing the values
  163.    of the fields, one per line.
  164.  - <database> is the name of the database to append the records to.
  165.  
  166. ?e
  167.  
  168. Export records to a file
  169. ========================
  170.  
  171. export [deleted] <database> [into <filename>]
  172.  
  173. Where
  174.  - <database> is the name of the database to export records from
  175.  - <filename> is the name of a file (ext .DAT) to receive the records.
  176.    If omitted, the records are written to the terminal.
  177.  - the "deleted" option exports those records that have been marked
  178.    as deleted since the file was created or compressed. It is used to
  179.    recover overambitious deletions.
  180.  - records are written to the output file one field per line.
  181.  
  182. ?e
  183.  
  184. Extract database definition
  185. ===========================
  186.  
  187. extract <database> [into <filename>]
  188.  
  189. Where
  190.  - <database> is the name of a database
  191.  - <filename> is a file (ext .DEF) to receive the definition.
  192.    If omitted, the definition is written to the terminal - this
  193.    is handy for reminding you what fields are defined.
  194.  - The definition is specified as the commands necessary to
  195.    create the database again at the current size.
  196.  
  197. ?c
  198.  
  199. Compress database file
  200. ======================
  201.  
  202. compress <database>
  203.  
  204. Where - <database> is a database name.
  205.  
  206. This compresses active records at the start of the database file,
  207. and frees up space at the end for further records to be added.
  208.  
  209. To reduce the size of the file as well, assuming there is sufficient
  210. disk space, the following sequence may be used instead
  211.  
  212.     DBQ> find all of <database>;
  213.     DBQ> print; # To check if everything is O.K. before erasing old file
  214.     DBQ> erase <database>
  215.     DBQ> rename current <database>
  216.  
  217. ?s
  218.  
  219. Sort a database
  220. ===============
  221.  
  222. sort <database> by <sname1> {, <sname2>} . . . ;
  223.  
  224. Where
  225.  - <database> is a database name
  226.  - <sname> is the name of a field to sort on, optionally followed
  227.    by "asc" (default) or "desc" meaning ascending or descending.
  228.  - The sort order is major through minor (e.g. <snameN> within <snameN-1>
  229.    . . . within <sname2> within <sname1>.
  230.  - Records are sorted in situ. It takes a while for a large database.
  231.  - It is not advisable to abort a sort halfway through - be patient.
  232.  - Unfortunately all sorting is done on the character value of the field,
  233.    so numerics do not get sorted numerically.
  234.  
  235. Example
  236. -------
  237.  
  238. sort accounts by name, balance descending;
  239.  
  240. ?e
  241.  
  242. Erase a database
  243. ================
  244.  
  245. erase <database>
  246.  
  247. Where - <database> is the name of a database
  248.  
  249. The named database file is erased from the disk. It cannot be
  250. recovered except by immediate use of a program such as UNERA.
  251.  
  252. ?r
  253.  
  254. Rename a database
  255. =================
  256.  
  257. rename <olddatabase> <newdatabase>
  258.  
  259. Where
  260.  - <olddatabase> is the existing name of a database
  261.  - <newdatabase> is the desired new name for the database
  262.  
  263. Example
  264. -------
  265.  
  266.     DBQ> find all of employees with dept = 300;
  267.     DBQ> rename current ourdept
  268.  
  269. ?d
  270.  
  271. Define a procedure
  272. ==================
  273.  
  274. define <procname>
  275.  
  276. Where
  277.  
  278.  - <procname> is the name of the procedure to be defined
  279.  
  280. DBQ prompts you for the definition on subsequent lines. An empty line
  281. is used to terminate the definition. As procedure definitions overwrite
  282. previous definitions, a null definition effectively deletes the procedure.
  283.  
  284. Example
  285. -------
  286.  
  287.     DBQ> define sum
  288.     DBQ-DEF> print all+ of
  289.     DBQ-DEF>
  290.     DBQ> sum accounts;
  291.  
  292. ?s
  293.  
  294. Show procedure definition
  295. =========================
  296.  
  297. show <procname>
  298.  
  299. Where
  300.  
  301.  - <procname> is the name of the procedure to be listed
  302.  
  303.  - if <procname> is replaced by a terminator or keyword,
  304.    a list of currently defined procedures is shown.
  305.  
  306. Example
  307. -------
  308.  
  309.     DBQ> show sum
  310.         print all+ of
  311.     DBQ> show ;
  312.         sum
  313.     DBQ>
  314.  
  315. ?e
  316.  
  317. Prompt for simple procedure value
  318. =================================
  319.  
  320. enter <procname>
  321.  
  322. Where - <procname> is an identifier
  323.  
  324. Causes a prompt to be issued for the identifier, and after reading one
  325. line, sets the procedure to that value. A null entry deletes the procedure.
  326. This is used in command files, and in other procedures, to prompt for input
  327. as part of a procedure of commands.
  328.  
  329. Example
  330. -------
  331.     DBQ> define findemp
  332.     DEFINE> enter empno:
  333.     DEFINE> print employees with empno = empno: ;
  334.     DEFINE>
  335.     DBQ> findemp
  336.     DBQ> Enter empno:
  337.  
  338. ?s
  339.  
  340. Set/unset options
  341. =================
  342.  
  343. set [no] [fold] [verify] [log] [page {nn}] ;
  344.  
  345. This permits options to be set, or unset if "no" is first specified.
  346.  
  347. The options are:-
  348.  
  349. fold    - permits alphabetic case folding on comparisons.
  350.       e.g. "FrEd" would match with "fReD"
  351. verify    - causes contents of command files to be output during execution.
  352. log    - causes input to be logged to the file DBQ.LOG
  353.           all log output for a run is concatenated, even if switched off
  354.           in between sections. The file is closed on 'exit'.
  355. page {nn} sets the page length to nn lines (or 66 if nn not specified).
  356.  
  357. Example
  358. -------
  359.  
  360. set fold no verify;
  361. Fold = 1, log = 0, page = 60, verify = 0
  362.  
  363. ?h
  364.  
  365. Help on topics
  366. ==============
  367.  
  368. help
  369.  
  370. This causes an initial page of help information to be output to the
  371. terminal. A prompt is then issued to press ^Z, ENTER, or a character.
  372. If ENTER is pressed, the next page of help is printed.
  373. If ^Z is pressed, the program returns to the DBQ> prompt.
  374. If a character is pressed, the next help page relating to a topic
  375. starting with that character is displayed.
  376.  
  377. Example
  378. -------
  379.     DBQ> help
  380.  
  381. ... page of help ...
  382. Press ^Z to abort, ENTER to continue, or x for help on x...
  383. c
  384.  
  385. ... page of help on "create" ...
  386.  
  387. ?e
  388.  
  389. Exit from DBQ
  390. =============
  391.  
  392. exit
  393.  
  394. This returns the user to the CPM+ prompt
  395.  
  396. ?f
  397.  
  398. Format file
  399. ===========
  400. The format file is used to provide a format for output, and can
  401. contain control specifiers (<,>,%,question mark) and free text.
  402.  
  403. Fields
  404. ------
  405. <field name> - is replaced by named field, space filled
  406.            to left for numbers and to right for strings
  407. >field name< - is replaced by named field with no space fill
  408.  
  409. Heading
  410. -------
  411. %Heading text
  412. %
  413. At the start of the format file causes the specified heading text
  414. to be output at the start of the output listing.
  415.  
  416. Pause
  417. -----
  418. A question mark at the end of the file causes a pause on every record.
  419.  
  420. ?@
  421.  
  422. Command files
  423. =============
  424.  
  425. @<filename>
  426.  
  427. Where - <filename> is the full name of a file containing commands.
  428.  
  429. This causes the contents of the specified file to be inserted at the
  430. current point in the input. The command file may contain any input,
  431. apart from the response to an "enter" request.
  432.  
  433. If "verify" is set, the contents of the file are output to the terminal
  434. as it is read.
  435.  
  436. If the file "DBQINIT.CMD" is present when DBQ is started, it is executed
  437. initially, and can be used to set up procedure definitions etc.
  438.  
  439. Comments can be inserted in a command file, or indeed in direct input,
  440. by preceding them with "#". Everything on a line after a "#" is ignored.
  441.  
  442. ?q
  443.  
  444. To quit type "exit"
  445.  
  446.  
  447. d in direct input,
  448. by preceding them with "#". Everything on a line after a "#" is